<link rel="stylesheet" href="<?php echo STATIC_URL.'/backend/css/notice.css'?>" />
<?php $this->load->view('templates/backend/lib'); ?>
<script>
function closeFancy(){
    parent.jQuery.fancybox.close();
}
function sending(){
    $("#submit").attr('disabled','disabled');
    $("#cancel").attr('disabled','disabled');
    $("#success").html("<img src='<?php echo STATIC_URL;?>/backend/images/icon/loading-2.gif' /> <br/> Vui lòng chờ");    
    setTimeout(function () {
        $.ajax(
            {
                url : '/auth/voucher/approve',
                type: "POST",
                data : { debts_id: $("#debts_id").val(),voucher_id: $("#voucher_id").val(),session_vb: $("#session_vb").val(),sale_fare:$("#sale_fare").val()},
                cache: true,
                beforeSend: function(){
                    $("#success").html("<img src='<?php echo STATIC_URL;?>/backend/images/icon/loading-2.gif' /> <br/> Đang xử lí");
                },
                success:function(data)
                {
                    setTimeout(function () {
                        if(data==0){
                                $("#success").html("Duyệt booking thành công!");
                                setTimeout(function () {
                                    closeFancy();
                                },1000);
                                
                        } else {
                            $("#success").html("Duyệt booking thất bại Hoặc Booking đã được duyệt rồi!");
                            setTimeout(function () {
                                closeFancy();
                            },1000);
                        }
                    },2000);
                },
                error: function() 
                {
                    $("#success").html("Duyệt booking thất bại!");
                }
            });
     },2000);
    
    
}
</script>

<div id="container2">
    <h3 id="nav2" class="logo">
        <a id="logo">VUI LÒNG XÁC NHẬN DUYỆT</a>
    </h3>
    
    <div id="wufoo-mz9i3ib0wkzqls">
        <?php
            if($approve->payment_confirm==0){
        ?>
                <p style="text-align: center;">VUI LÒNG XÁC NHẬN DUYỆT</p>
                <ul>
                    <li><?php echo $this->lang->line("booking_place_code").' : '.  implode(",", json_decode($approve->booking_place_code)); ?></li>
                    <li><?php echo $this->lang->line("net_fare").' : '.$this->bookinglib->my_number_format($approve->net_fare, 2, ',', ',').' VND'; ?></li>
                    <li><?php echo $this->lang->line("sale_fare").' : '.$this->bookinglib->my_number_format($approve->sale_fare, 2, ',', ',').' VND'; ?></li>
                    <li><?php echo $this->lang->line("reason").' : '.$approve->reason;?></li>
                    <li><?php echo $this->lang->line("maturity").' : '.date("d-m-Y",$approve->debts);?></li>
                </ul>
                
                <?php echo form_input(array('type'=>'hidden', 'name' => 'session_vb', 'id' => 'session_vb', 'value' => md5(time())));?>
                <?php echo form_input(array('type'=>'hidden', 'name' => 'voucher_id', 'id'=>'voucher_id', 'value' => $approve->voucher_id));?>
                <?php echo form_input(array('type'=>'hidden', 'name' => 'debts_id', 'id'=>'debts_id', 'value' => $approve->id));?>
                <?php echo form_input(array('type'=>'hidden', 'name' => 'sale_fare', 'id'=>'sale_fare', 'value' => $approve->sale_fare));?>
                
                <div class="top-button">
                        <?php echo form_button(array('id' => 'submit', 'name' => 'submit', 'content' => $this->lang->line('check'),'class' => 'btn btn-primary','onclick'=>'sending()')); ?>
                        <?php echo form_button(array('id' => 'cancel','content' => $this->lang->line('close'),'class' => 'btn','onclick'=>'closeFancy()')); ?>
                </div>
                <div id="success"></div>
        <?php
            } else {
                echo '<p style="text-align: center;">BOOKING NÀY ĐÃ ĐƯỢC DUYỆT RÙI! <br/>VUI LÒNG ĐÓNG LẠI VÀ DUYỆT BOOKING KHÁC!</p>';
                echo '<div class="top-button">'.form_button(array('id' => 'cancel','content' => $this->lang->line('close'),'class' => 'btn','onclick'=>'closeFancy()')).'</div>';
            }
        ?>
    </div>
</div>
